package Middleware

import (
	"fmt"
	"github.com/astaxie/beego/context"
	"github.com/syyongx/php2go"
	"hello/wl"
)

func ValidateToken(ctx *context.Context){

	redisClient:=wl.WLRedis()
	key:= ctx.Input.Query("token")

	TokenVal, err := redisClient.Get(key).Bytes()
	if err != nil {
		panic(err)
	}

	fmt.Println("验证Token",TokenVal)

	if php2go.Empty(TokenVal) {
		ctx.Output.JSON(wl.AjaxError("登陆失去!"), true,false)
		panic("stop")
		fmt.Println("异常")
		return
	}

}
